import { createRouter, createWebHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'
import userRouter from "@/router/modules/user";
import loanRouter from "@/router/modules/loan";
import system from "@/router/modules/system";
import Permission from "@/router/modules/permission";


// 静态路由
const staticRoutes: RouteRecordRaw[] = [
  {
    path: '/login',
    component: () => import('@/views/login/LoginView.vue')
  },
  {
    path: '/',
    component: () => import('@/layout/Index.vue'),
    redirect: '/dashboard',
    children: [
      {
        path: '/dashboard',
        component: () => import('@/views/dashboard/IndexView.vue'),
        meta: {
          title: '首页',
          icon: 'index',
          level: 1,
          hasChild: false
        }
      },
      {
        path: '/approve',
        component: () => import('@/views/approve/IndexView.vue'),
        meta: {
          title: '审批',
          icon: 'crop',
          level: 1,
          hasChild: false
        }
      },
    ]
  },
  {
    path: '/404',
    component: () => import('@/views/404/NotFound.vue')
  },
  {
    path: '/:pathMatch(.*)*',
    redirect: '/404'
  }
]

// 动态路由
const asyncRouts = [userRouter,loanRouter,system,Permission]


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    ...staticRoutes, ...asyncRouts
  ]
})

export default router
